package work.mediway.mdm.core.handler;

import com.mediway.hos.common.utils.poi.ExcelHandlerAdapter;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import work.mediway.mdm.core.util.DUtil;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/5/23
 */
public class ExcelDateHandler implements ExcelHandlerAdapter {
    @Override
    public Object format(Object o, String[] strings) {
        if (ObjectUtil.isNotEmpty(o)) {
            if (DUtil.isDateTime(o.toString())) {
                return DateUtil.parseDateTime(o.toString());
            } else if (DUtil.isDate(o.toString())) {
                return DateUtil.parseDate(o.toString());
            } else if (DUtil.isTime(o.toString())) {
                return DateUtil.parseTime(o.toString());
            }
        }
        return o;
    }
}
